import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace SysAbsenceRuleApi {
  /** 离岗规则信息 */
  export interface SysAbsenceRule {
    id: number; // 编号
    startTime?: string; // 开始时间，如：09:00:00
    endTime?: string; // 结束时间，如：17:30:00
    absenceThreshold?: number; // 违规临界值，分钟
    status?: number; // 状态，0关闭1开启
    ruleAlias?: string; // 别名
    ruleDesc: string; // 规则描述
  }
}

/** 查询离岗规则分页 */
export function getSysAbsenceRulePage(params: PageParam) {
  return requestClient.get<PageResult<SysAbsenceRuleApi.SysAbsenceRule>>('/moxi/sys-absence-rule/page', { params });
}

/** 查询离岗规则详情 */
export function getSysAbsenceRule(id: number) {
  return requestClient.get<SysAbsenceRuleApi.SysAbsenceRule>(`/moxi/sys-absence-rule/get?id=${id}`);
}

/** 新增离岗规则 */
export function createSysAbsenceRule(data: SysAbsenceRuleApi.SysAbsenceRule) {
  return requestClient.post('/moxi/sys-absence-rule/create', data);
}

/** 修改离岗规则 */
export function updateSysAbsenceRule(data: SysAbsenceRuleApi.SysAbsenceRule) {
  return requestClient.put('/moxi/sys-absence-rule/update', data);
}

/** 删除离岗规则 */
export function deleteSysAbsenceRule(id: number) {
  return requestClient.delete(`/moxi/sys-absence-rule/delete?id=${id}`);
}

/** 批量删除离岗规则 */
export function deleteSysAbsenceRuleList(ids: number[]) {
  return requestClient.delete(`/moxi/sys-absence-rule/delete-list?ids=${ids.join(',')}`)
}

/** 导出离岗规则 */
export function exportSysAbsenceRule(params: any) {
  return requestClient.download('/moxi/sys-absence-rule/export-excel', params);
}

